
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class FmsMaterialPrecisionTemplateServiceImpl implements FmsMaterialPrecisionTemplateService  {

    @Resource
    private FmsMaterialPrecisionTemplateMapper fmsMaterialPrecisionTemplateMapper;

    /**
     * 获取 FmsMaterialPrecisionTemplate 分页列表
     */
    @Transactional
    public IPage getFmsMaterialPrecisionTemplatePagination( PaginationVo paginationVo, FmsMaterialPrecisionTemplateQuery fmsMaterialPrecisionTemplateQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<FmsMaterialPrecisionTemplateEntity> lqs = new LambdaQueryWrapper();
        fmsMaterialPrecisionTemplateMapper.selectPage(page, lqs);

        List<FmsMaterialPrecisionTemplateEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 FmsMaterialPrecisionTemplate 所有数据
     *
    */
    @Transactional
    public List<FmsMaterialPrecisionTemplateEntity> getFmsMaterialPrecisionTemplateAllList( FmsMaterialPrecisionTemplateQuery fmsMaterialPrecisionTemplateQuery ) throws Exception {

        LambdaQueryWrapper<FmsMaterialPrecisionTemplateEntity> lqs = new LambdaQueryWrapper();
        List<FmsMaterialPrecisionTemplateEntity> list = fmsMaterialPrecisionTemplateMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 FmsMaterialPrecisionTemplate 详情
    */
    @Transactional
    public FmsMaterialPrecisionTemplateEntity getFmsMaterialPrecisionTemplateDetail( Long id) throws Exception {

        FmsMaterialPrecisionTemplateEntity fmsMaterialPrecisionTemplate = fmsMaterialPrecisionTemplateMapper.selectById(id);
        return fmsMaterialPrecisionTemplate;
    }


    /**
     * 新增 FmsMaterialPrecisionTemplate
     * */
    @Transactional
    public void addFmsMaterialPrecisionTemplate(FmsMaterialPrecisionTemplateVo fmsMaterialPrecisionTemplateVo) throws Exception {

        FmsMaterialPrecisionTemplateEntity fmsMaterialPrecisionTemplate = new FmsMaterialPrecisionTemplateEntity();
        ReflectionCopy.copyProperties( fmsMaterialPrecisionTemplate, fmsMaterialPrecisionTemplateVo );
        fmsMaterialPrecisionTemplateMapper.insert(fmsMaterialPrecisionTemplate);
        return;
    }


    /**
     * 更新 FmsMaterialPrecisionTemplate
     * */
    @Transactional
    public void updateFmsMaterialPrecisionTemplate( FmsMaterialPrecisionTemplateVo fmsMaterialPrecisionTemplateVo) throws Exception {

        if( fmsMaterialPrecisionTemplateVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        FmsMaterialPrecisionTemplateEntity fmsMaterialPrecisionTemplate = new FmsMaterialPrecisionTemplateEntity();
        ReflectionCopy.copyProperties( fmsMaterialPrecisionTemplate, fmsMaterialPrecisionTemplateVo );
        fmsMaterialPrecisionTemplateMapper.updateById(fmsMaterialPrecisionTemplate);
        return;
    }

    /**
     * 删除 FmsMaterialPrecisionTemplate
     * */
    @Transactional
    public void batchRemoveFmsMaterialPrecisionTemplate( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        fmsMaterialPrecisionTemplateMapper.deleteBatchIds(ids);
    }

}

      